Add application-id to role schema to connect role to OpenSearch Dashboards menu item#86
Open
Add application-id to role schema to connect role to OpenSearch Dashboards menu item#86
Conversation
…oards menu item Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add
application_idfield to the role schema and introduce a new REST endpoint (GET _plugins/_security/applicationpermissions) that returns the list of application IDs the current user has access to. This enables OpenSearch Dashboards to selectively show/hide menu items based on which plugin applications a user is authorized to access.Currently, Dashboards menu visibility is limited to three coarse-grained levels: regular users (see everything except Security), read-only users (basically just Discover), and security admins (see everything). There is no way for a cluster admin to selectively hide menu items like Index Management or Alerting. This leads to poor UX where users navigate to pages they don't have permissions for and get Access Denied errors.
Old behavior: No association between roles and Dashboards applications. Menu visibility is controlled only by
readonly_mode.rolesandrestapi.roles_enabledsettings.New behavior: Plugins can declare an
application_idon their default roles (indefault-roles.yml), creating a strong association between the role and a specific Dashboards application. The newGET _plugins/_security/applicationpermissionsendpoint resolves the current user's mapped roles and returns the distinct set ofapplication_ids they have access to. Users mapped toall_accessreceive["*"]. Users with no application-linked roles receive[].Example response:
{ "user_name": "analyst_user", "application_ids": ["security-analytics", "index-management"] }Issues Resolved
Resolves opensearch-project#5635
This is not a backport.
These changes introduce a new REST endpoint (
_plugins/_security/applicationpermissions) but no new permissions to be displayed in the static dropdown. A companion security-dashboards-plugin PR will be needed to consume this endpoint for menu management.Testing
RoleV7Testverifyingapplication_iddeserialization from YAML and null when absentApplicationPermissionsInfoTestwith 5 test cases:all_accessuser receives["*"]user_name./gradlew test --tests "org.opensearch.security.securityconf.impl.v7.RoleV7Test"(6/6 pass, 0 failures)Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check [here](https://github.com/opensearch-project/security/blob/main/CONTRIBUTING.md#developer-certificate-of-origin).
Your working title looks good. Want me to write this into
PR_DESCRIPTION.mdor are you copying it straight into GitHub?